#include "comm.hpp"

int main()
{
    int wfd = open(NAME_PIPE, O_WRONLY);
    if(wfd < 0)
    {
        cout << "errno: " << errno << "err string: " << strerror(errno) << endl;
        exit(1);
    }
    //write
    char buffer[1024];
    while(1)
    {
        cout << "进程A# ";
        fgets(buffer, sizeof(buffer) - 1, stdin);
        if(strlen(buffer) > 0)
            buffer[strlen(buffer) - 1] = 0;
        ssize_t n = write(wfd,  buffer, strlen(buffer));
        assert(n == strlen(buffer));
        (void)n;
    }

    close(wfd);
    return 0;
}